package com.it.utils;

import java.sql.SQLException;

public class TransactionManager {
    /**
     * 开始事务
     *
     * @throws SQLException
     */
    public static void beginTransaction() throws SQLException {
        System.out.println("开启事务");
        ConnectionUtils.getConection().setAutoCommit(false);
    }

    /**
     * 提交事务
     *
     * @throws SQLException
     */
    public static void commitTransaction() throws SQLException {
        System.out.println("提交事务");
        ConnectionUtils.getConection().commit();
      //  ConnectionUtils.getConection().close();
    }

    /**
     * 回滚事务
     *
     * @throws SQLException
     */
    public static void rollBackTransaction() throws SQLException {
        System.out.println("回滚事务");
        ConnectionUtils.getConection().rollback();
      //  ConnectionUtils.getConection().close();
    }

}
